package com.generator.sysManage.logManage.control;

import com.generator.aboutUser.log.service.impl.LogService;
import com.generator.sysManage.logManage.pojo.Log;
import com.generator.util.LogCondition;
import com.generator.util.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @version 1.0
 * @auther wumei
 * @date 2022/10/03
 * 星期一 18:32
 */
@Controller
@RequestMapping("/logManage")
public class LogManageController {

    @Autowired
    private LogService logService;

    public LogService getLogService() {
        return logService;
    }
    public void setLogService(LogService logService) {
        this.logService = logService;
    }


    /**
     * 分页拿出日志信息
     * @param logCondition
     * @param pageModel
     * @return
     */
    @RequestMapping("/logList")
    public String getLogsByCondition(LogCondition logCondition, PageModel<Log> pageModel, Model model) {
        PageModel<Log> logList = logService.getLogsByCondition(logCondition,pageModel);
        model.addAttribute("logList",logList);
        return "sys/logs/logList";
    }

    /**
     * 查看日志详情
     * @param log
     * @return
     */
    @RequestMapping("/getLogDetail/{jId}")
    public String getLogDetail(Log log,Model model){
        if (log != null){
            Log logDetail = logService.queryLogById(log);
            model.addAttribute("logDetail",logDetail);
            System.out.println(logDetail);
        }
        return "sys/logs/logView";
    }



}
